public class Text5 {
    //笔试强训 day16 第一题  字符串的替换
    public static void main(String[] args) {

    }
    public String formatString (String str, char[] arg) {
        //简单
        //先找到%s
        StringBuffer result = new StringBuffer(str);
        int index = 0;
        for(int i = 0; i < result.length(); i++) {
            if(result.charAt(i) == '%' && result.charAt(i+1) == 's') {
                if(index < arg.length) {
                    result.replace(i,i+2,String.valueOf(arg[index++]));
                }else{

                    break;
                }
            }
        }
        //长度大于就拼接在后面
        for(int i = index; i < arg.length; i++) {
            result.append(arg[i]);
        }
        return result.toString();
    }
}
